home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / login / sac-1.000 / sac-1 / sac-1.3.1 / scripts / check next >
Text File  |  1996-05-27  |  1KB  |  39 lines

  1. #!/bin/sh
  2. #
  3. #  Check checks to see if any of the people who are logged in at the time
  4. # have used up their allotment of time (as specified by MAXHOURS) on the
  5. # modems (as specified by TTYS).
  6. #
  7.  
  8. MAXHOURS=4.25
  9. #TTYS='ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 ttyC6 ttyC7'
  10. TTYS="tty1 tty2 tty3 tty4 tty5 tty6 ttyp0 ttyp1 ttyp2 ttyp3"
  11.  
  12. hours=`date +%H:%M:%S`
  13. users=`users`
  14.  
  15. u=`for x in $users; do echo $x; done | sort | uniq`
  16.  
  17. sac -pb $hours $u -T $TTYS | while read user hours
  18. do
  19.   if [ `expr $hours '<=' $MAXHOURS` -eq 1 ]; then
  20.     echo "$user is OK. ($hours)"
  21.   else
  22.     echo "$user is over the limit. ($hours)"
  23.   fi
  24. done
  25.  
  26. # If you use Sac to implement usage limits, the above can be modified to
  27. # "logout" the user by modifing the above if statement to the below:
  28. #
  29. #  if [ `expr $h '<=' $MAXHOURS` -eq 0 ]; then
  30. #    echo "You're over the time limit bozo! ($h) Bye Bye!" | write $user
  31. #    ps augx | tail +2 | while read usr PID whatever
  32. #    do
  33. #      if [ $usr = $user ]; then kill -9 $PID; fi
  34. #    done
  35. #  fi
  36. #
  37. # Running this script every 5-10 minutes in a cron job wouldn't be a bad idea
  38. # either.
  39.